#pragma once
#include <type_traits>
#include <iostream>
using std::ostream;

#include "../public/constants.hpp"
#include "../public/exception.hpp"
#include "../allocator/defaloc.hpp"
#include "../iterator/iterator_traits.hpp"

#include "../container/deque.hpp"

namespace bla {
	/*
	 * template para:
	 * _type : all container have, can be any type
	 * _allocator: suggest using the default value: the default is _defaloc class
	 */
	template<typename _type, typename _allocator = _defaloc<_type>>
	class stack {
	private:
		deque<_type, _allocator> _deque;
	public:
		stack() : _deque(deque<_type, _allocator>()) { ; };

		/*
		 * push
		 */
		void push(_type v) {
			this->_deque.push_back(v);
		}

		/*
		 * if not empty, pop and return true
		 * else return false
		 */
		bool pop() {
			if (!this->empty()) {
				this->_deque.pop_back();
				return true;
			}
			else {
				return false;
			}
		}

		/*
		 * if not empty, return the top value
		 * else return dump value(_type())
		 */
		_type top() {
			if (!this->empty()) {
				return this->_deque[this->_deque.size() - 1];
			}
			else {
				return _type();
			}
		}

		/*
		 * return if it is empty
		 */
		bool empty() {
			return this->_deque.empty();
		}
	};
}


